package Serial;
use strict;
use Carp;

## Class Data

my %conf=(
	'start' => 1,
	'increment' => 1,
);

## Configuration

sub configure {
	my $pkg=shift;
	return unless @_;
	while (my $key=shift) {
		my $value=shift;
		$key=~/start/ and $conf{'start'}=int($value), next;
		$key=~/increment/ and do {
			$value=int($value);
			croak "Invalid value '$_'" unless $value;
			$conf{'increment'}=$value;
			next;
		};
		croak "Invalid name '$key' in import list";	
	}
}

sub check {
	my $value=shift;
}

sub import {
	shift->configure(@_);
}

## Constructor

sub new {
	my $class=(ref $_[0]) || $_[0];
	$conf{'start'}=$_[1] if defined $_[1];

	my $self=bless {}, $class;
	$self->{'serial'}=$conf{'start'};
	$conf{'start'}+=$conf{'increment'};
	return $self;
}

## Object Methods

sub serial {
	return shift->{'serial'};
}

1;
